﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Utilities.Common
{
    public static class ClassInfoCache
    {
        static Dictionary<string, ClassInfo> Cache = new Dictionary<string, ClassInfo>();

        public static ClassInfo GetClassInfo(object obj)
        {
            if (obj != null)
            {
                ClassInfo clase = null;
                string name = obj.GetType().Name;
                if (Cache.ContainsKey(name))
                {
                    clase = Cache[name];
                }
                else
                {
                    clase = ClassInfo.BuildClassInfo(obj);
                    Cache.Add(name, clase);
                }

                return clase;
            }
            return null;
        }
    }
}
